package com.wenshi.system.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wenshi.system.domain.SysDevice;
import com.wenshi.system.mapper.SysDeviceMapper;
import com.wenshi.system.service.ISysDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper,SysDevice> implements ISysDeviceService {


    @Autowired
    ISysDeviceService sysDeviceService;

    @Override
    public boolean updateDeviceByIp(String ip, Boolean status) {
        QueryWrapper<SysDevice> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("device_ip", ip);
        SysDevice sysDevice = baseMapper.selectOne(queryWrapper);
        sysDevice.setDeviceStatus(status);
        int i = baseMapper.updateById(sysDevice);
        if (i>0){
            return  true;
        }
        return false;
    }

    @Override
    public SysDevice getByDeviceIp(String deviceIp) {
        QueryWrapper<SysDevice> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("device_ip", deviceIp);
        SysDevice sysDevice = baseMapper.selectOne(queryWrapper);
        return sysDevice;
    }
}
